<?php

class Login extends Controller {
	
	function Login()
	{
		parent::Controller();
		$this->load->model('Administrator_model');
	}
	
	function index() {
		//--get value from form
		$ary_info = array(
			'email' => $this->input->post('tf_email'),
			'password' => dohash($this->input->post('tf_password')),	
		);				
			
		if ($this->input->post('btn_login')) {
			$result = $this->Administrator_model->getAdministrator($ary_info);
			
			if (count($result)>0) {								
				$this->session->set_userdata(array(
					'ss_email'=>$result['email'],
				));
				redirect('administrator/home');
			}
			$data['inc_script'] = '';
			$this->load->view('administrator/login_view',$data);
		}		
	}
}